package myDesiign.com.song;

import myDesiign.com.song.factory.MyFactory;
import myDesiign.com.song.service.IMyService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @Author Klys
 * @Date 2023/6/19 10:18
 * @Description
 * @Version 1.0
 */
@SpringBootApplication
public class MyTest {
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(MyTest.class, args);
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String str :
                beanDefinitionNames) {
            System.out.println(str);
        }

        MyFactory myFactory1 = (MyFactory) applicationContext.getBean("myFactory");
        System.out.println(myFactory1);
        IMyService myService1 = myFactory1.getMyService(3);
        System.out.println(myService1);

//        调用业务
        String add = myService1.add();
        System.out.println(add);
    }
}
